package conf2.model;

import conf2.model.EActor.Side;

public class GameState
{

    private int currentRound = 1;
    private int homeScore = 0,  awayScore = 0;
    private boolean homeIsServer;
    private boolean isHomeTurn;
    private String myName,  opponentName;
    private Side serverSide;
    private GameType gameType;
    private ShelobRule shelobRule;
    private SpecialCardRule specialCardRule;
    private int numberOfSpecialCards;
    private ESpecialCard[] mySpecialCards = null,  opponentSpecialCards = null;
    private Deck myDeck,  opponentDeck;

    public Side getMySide()
    {
        return (homeIsServer ? serverSide : Side.opposing(serverSide));
    }

    public Side getOpponentSide()
    {
        return (homeIsServer ? Side.opposing(serverSide) : serverSide);
    }

    public boolean isMyTurn()
    {
        return isHomeTurn;
    }

    public boolean iAmServer()
    {
        return homeIsServer;
    }

    public int getCurrentRound()
    {
        return currentRound;
    }

    public int getMyScore()
    {
        return homeScore;
    }

    public int getOpponentScore()
    {
        return awayScore;
    }

    private GameState()
    {
    }

    public GameState(boolean iAmServer, Side serverSide, String myName, String opponentName, GameType gameType, ShelobRule shelobRule, SpecialCardRule scr)
    {
        homeIsServer = iAmServer;
        this.serverSide = serverSide;
        this.myName = myName;
        this.opponentName = opponentName;
        this.gameType = gameType;
        this.shelobRule = shelobRule;
        this.specialCardRule = scr;
        isHomeTurn = (iAmServer ? serverSide == Side.DARK : serverSide == Side.LIGHT);
        myDeck = new Deck(getMySide());
        opponentDeck = new Deck(getOpponentSide());
    }

    public int getNumberOfSpecialCards()
    {
        return numberOfSpecialCards;
    }

    public void setNumberOfSpecialCards(int i)
    {
        numberOfSpecialCards = i;
    }

    public void addToMyScore(int score)
    {
        homeScore += score;
    }

    public void addToOpponentScore(int score)
    {
        awayScore += score;
    }

    public void setIAmServer(boolean b)
    {
        homeIsServer = b;
    }

    public void setIsMyTurn(boolean b)
    {
        isHomeTurn = b;
    }

    public void nextRound()
    {
        currentRound++;
    }

    public void nextTurn()
    {
        isHomeTurn = !isHomeTurn;
    }

    public String getMyName()
    {
        return myName;
    }

    public String getOpponentName()
    {
        return opponentName;
    }

    public Side getServerSide()
    {
        return serverSide;
    }

    public GameType getGameType()
    {
        return gameType;
    }

    public ShelobRule getShelobRule()
    {
        return shelobRule;
    }

    public SpecialCardRule getSpecialCardRule()
    {
        return specialCardRule;
    }

    public ESpecialCard[] getMySpecialCards()
    {
        return mySpecialCards;
    }

    public void setMySpecialCards(ESpecialCard[] mySpecialCards)
    {
        this.mySpecialCards = mySpecialCards;
    }

    public ESpecialCard[] getOpponentSpecialCards()
    {
        return opponentSpecialCards;
    }

    public void setOpponentSpecialCards(ESpecialCard[] opponentSpecialCards)
    {
        this.opponentSpecialCards = opponentSpecialCards;
    }

    public Deck getMyDeck()
    {
        return myDeck;
    }

    public Deck getOpponentDeck()
    {
        return opponentDeck;
    }
}
